<?php

class PublicationReview {
	private $id;
	private $id_user;
	private $id_publication;
	private $updateDate;
	
	function __construct($id,$id_user,$id_publication,$updateDate){
		$this -> id 			= $id;
		$this -> id_user 		= $id_user;
		$this -> id_publication = $id_publication;
		$this -> updateDate 	= $updateDate;
	}
	
	function getResourcesType($db,$id){
		$result			= $db->query("SELECT * FROM publication_review WHERE pr_IDreview = $id",2);
		$publicationReview 	= new PublicationReview(	
							$result[0]['rt_IDtype'],
							$result[0]['rt_description']);
		return $publicationReview;
	}
	/*Insert*/
	function insert($db,$publicationReview){
		$id_user 		= $publicationReview -> getIDuser();
		$id_publication = $publicationReview -> getIDpublication();
		$updateDate 	= $publicationReview -> getUpdateDate();
		$result			= $db -> insert("INSERT INTO publication_review (pr_id_user,pr_id_publication,pr_updateDate)
										 VALUES($id_user,$id_publication,now())");
		return $result;
	}
	/*Delete*/
	function delete($db,$publicationReview){
		$id 	= $publicationReview -> getIDpublicationReview();
		$result = $db -> delete("DELETE FROM publication_review WHERE pr_IDreview = $id");
		return $result;
	}
	/*Modify*/
	function update($db,$publicationReview){
		$id 			= $publicationReview -> getIDpublicationReview();
		$id_user 		= $publicationReview -> getIDuser();
		$id_publication = $publicationReview -> getIDpublication();
		$updateDate 	= $publicationReview -> getUpdateDate();
		$result = $db -> update ("UPDATE publication_review SET pr_id_user 			= $id_user,
																pr_id_publication 	= $id_publication,
																pr_updateDate		= $updateDate
													  WHERE pr_IDreview = $id");
		return $result;
	}
	
	/*ID publication review*/
	function getIDpublicationReview(){
		return $this -> id;
	}	
	function setIDpublicationReview($id){
		$this -> id = $id;
	}	
	/*ID user*/
	function getIDuser(){
		return $this -> id_user;
	}	
	function setIDuser($id_user){
		$this -> id_user = $id_user;
	}	
	/*ID publication*/
	function getIDpublication(){
		return $this -> id_publication;
	}	
	function setIDpublication($id_publication){
		$this -> id_publication = $id_publication;
	}	
	/*Update date*/
	function getUpdateDate(){
		return $this -> updateDate;
	}	
	function setUpdateDate($updateDate){
		$this -> updateDate = $updateDate;
	}	
}

?>